package com.kaishengit.test;

import java.io.FileOutputStream;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

public class Demo {

	public static void main(String[] args)throws Exception {
        //声明一个工作薄
        HSSFWorkbook wb=new HSSFWorkbook();
        //生成一个表格
        HSSFSheet sheet=wb.createSheet("表格1");
        for(int r=0;r<3;r++){
        	//生成一个列
        		HSSFRow row=sheet.createRow(r);
                //填充单元格
                String str[]=new String[5];
                str[0]="姓名";
                str[1]="密码";
                str[2]="职位";
                str[3]="公司";
                str[4]="电话";
                		
                for(short i=0;i<5;i++){
                    //声明一个单元格
                    @SuppressWarnings("deprecation")
					HSSFCell cell=row.createCell(i);
                    //设置单元格的字符值
                    cell.setCellValue(new HSSFRichTextString(str[i]));
                }
        }
        
        FileOutputStream fout=new FileOutputStream("c:/hehe.xls");
        //输出到文件
        wb.write(fout);
        fout.close();
    }

}
